/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {string[]}
 */
 var binaryTreePaths = function(root) {
    let res=[];
    if(!root){
        return res;
     }
    function digui(root,path){
        if(!root){
            return ;
        }
        else if(!root.left && !root.right){
            path +=root.val.toString();
            res.push(path);
            return ;
        }
        else{
            path+=root.val.toString()+'->';
            digui(root.left,path);
            digui(root.right,path);
        }
        
    }
    digui(root,'');
    return res;
};